/**
 * GeoJSON 基础类型
 */
type GeoJsonGeometryType =
    | "Point"
    | "MultiPoint"
    | "LineString"
    | "MultiLineString"
    | "Polygon"
    | "MultiPolygon"
    | "GeometryCollection"
    | "Feature"
    | "FeatureCollection";

/**
 * GeoJSON 位置坐标
 */
type Position = [number, number]; // 经度, 纬度
type PositionArray = Position | Position[];

/**
 * GeoJSON 几何对象基础接口
 */
interface GeoJsonGeometry {
    type: GeoJsonGeometryType;
}

/**
 * 点几何
 */
interface Point extends GeoJsonGeometry {
    type: "Point";
    coordinates: Position;
}

/**
 * 多点几何
 */
interface MultiPoint extends GeoJsonGeometry {
    type: "MultiPoint";
    coordinates: Position[];
}

/**
 * 线串几何
 */
interface LineString extends GeoJsonGeometry {
    type: "LineString";
    coordinates: Position[];
}

/**
 * 多线串几何
 */
interface MultiLineString extends GeoJsonGeometry {
    type: "MultiLineString";
    coordinates: Position[][];
}

/**
 * 多边形几何
 */
interface Polygon extends GeoJsonGeometry {
    type: "Polygon";
    coordinates: Position[][][];
}

/**
 * 多多边形几何
 */
interface MultiPolygon extends GeoJsonGeometry {
    type: "MultiPolygon";
    coordinates: Position[][][][];
}

/**
 * 几何集合
 */
interface GeometryCollection extends GeoJsonGeometry {
    type: "GeometryCollection";
    geometries: GeoJsonGeometry[];
}

/**
 * 要素特性
 */
interface Feature<G extends GeoJsonGeometry = GeoJsonGeometry> {
    type: "Feature";
    geometry: G;
    properties?: Record<string, any>;
    id?: string | number;
}

/**
 * 要素集合
 */
interface FeatureCollection<G extends GeoJsonGeometry = GeoJsonGeometry> {
    type: "FeatureCollection";
    features: Feature<G>[];
}

/**
 * 完整的 GeoJSON 对象类型
 */
type GeoJsonObject =
    | Point
    | MultiPoint
    | LineString
    | MultiLineString
    | Polygon
    | MultiPolygon
    | GeometryCollection
    | Feature
    | FeatureCollection;

export default {
    Point,
    MultiPoint,
    LineString,
    MultiLineString,
    Polygon,
    MultiPolygon,
    GeometryCollection,
    Feature,
    FeatureCollection
}